An encoder of a magnetic system is known that uses a magnetic medium in which N-poles and S-poles are so disposed as to alternately line and detects the amount of movement by detecting change in the leakage magnetic field from a magnetic medium by a magnetic sensor that moves relative to this magnetic medium (Patent Document 1).
The detection accuracy of this encoder becomes higher as a pitch λ at which the magnetization direction is made different is set shorter. However, when the pitch λ is set short, the leakage magnetic field from the magnetic medium surface becomes small. Thus, it becomes difficult to obtain a sufficient output signal unless the magnetic sensor is brought so close to the magnetic medium as to get contact with the magnetic medium and slide thereon.
An example of the output signal when the magnetic sensor moves on the magnetic medium is shown in FIG. 15A. When this signal is represented with orders of included signal components, as shown in FIG. 15B, signals of odd-order harmonics are included besides the primary signal (fundamental) originally required. Although the component of the harmonic becomes smaller as the order thereof becomes higher, the detection accuracy of the signal deteriorates due to this harmonic in some cases. In a certain example, when the amplitude of the primary signal (fundamental) is defined as 100%, the amplitudes of harmonics are as follows: the amplitude of the third-order harmonic is 30% of the amplitude of the fundamental; the amplitude of the fifth-order harmonic is 10% of the amplitude of the fundamental; and the signal of the seventh-order harmonic is 5% in turn.
Conventionally, in order to cancel such harmonics, as shown in FIG. 16, a harmonic cancelling pattern for cancelling out the harmonics is provided at a position offset from a first magnetoresistive element as a magneto-sensitive element by a predetermined distance (λ/(2n) in the case of the n-th-order harmonic, wherein λ is the magnetization pitch of the magnetic medium). Specifically, in Patent Document 2, an example of a position detector that reads position information whose cycle changes with a fundamental wavelength λ written to a scale by a magnetic sensor is disclosed. The magnetic sensor includes first, second, and third magnetoresistive elements that output the position information by a predetermined signal, and the second and third magnetoresistive elements are disposed on both sides of the first magnetoresistive element at an interval δ and are connected in series. In this example, based on the idea that the n-th-order harmonic is canceled by satisfying a condition of r+2 cos(2nπδ/λ)=0 (n is an odd number equal to or larger than 3) when the ratio of the outputs of the first magnetoresistive element and the second and third magnetoresistive elements is r, the output ratio r of the respective magnetoresistive elements is adjusted.
In Patent Document 3, an example is disclosed in which MR elements are used as magnetoresistive elements and the MR elements are disposed with offset of positions by an interval of (n/2±m/(2k))×λ, wherein the pitch of NS of the signal magnetic field is λ, n is an integer, m is an odd number, and the order of the harmonic is k (e.g. a configuration of FIG. 14 intended to cancel the seventh-order harmonic). However, in this Patent Document 3, no disclosure is made about the spin-valve GMR element. The MR element is referred to also as the AMR element.